<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>我发布的众筹项目</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../include/commonFile.jsp" %>
</head>
<body>
<!--头部-->
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <%--<div class="layui-tab-item layui-show">
                <div class="layui-tab layui-tab-brief" lay-filter="type">
                    <ul class="layui-tab-title" id="copartner_tab">
                        <li data-isCopartner="2" <c:if test="${activity.isCopartner == 2}"> class="layui-this"</c:if>>
                            我发布
                        </li>
                        <li data-isCopartner="1" <c:if test="${activity.isCopartner == 1}">class="layui-this"</c:if>>
                            合作渠道发布
                        </li>
                    </ul>
                    <div class="layui-tab-content">--%>
                        <form class="layui-form" action="${ctx}/activity/activity/zcActivityList.do" id="myForm" method="post">
                            <input type="hidden" name="pageNo" id="pageNo"/>
                            <input type="hidden" name="eventId" value="${activity.eventId}"/>
                            <input type="hidden" name="isCopartner" id="isCopartner" value="${activity.isCopartner}"/>

                            <div class="f-search-bar">
                                <div class="search-container">
                                    <ul class="search-form-content">
                                        <li class="form-item-inline"><label class="search-form-lable">项目名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="title" autocomplete="off" class="layui-input" value="${activity.title}" placeholder="请输入众筹项目名称">
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">主题名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="eventName" autocomplete="off" class="layui-input" value="${eventName}" placeholder="请输入众筹主题名称">
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">项目状态</label>
                                            <div class="layui-input-inline">
                                                <select name="timeStatus">
                                                    <option value="">全部</option>
                                                    <option value="0" ${input.timeStatus == 0 ? 'selected' : ''}>进行中</option>
                                                    <option value="1" ${input.timeStatus == 1 ? 'selected' : ''}>已截止</option>
                                                </select>
                                            </div>
                                        </li>
                                        <li class="form-item-inline"><label class="search-form-lable">项目类型</label>
                                            <div class="layui-input-inline">
                                                <select name="isMultiple">
                                                    <option value="">全部</option>
                                                    <option value="0" ${isMultiple == 0 ? 'selected' : ''}>单场</option>
                                                    <option value="1" ${isMultiple == 1 ? 'selected' : ''}>多场</option>
                                                </select>
                                            </div>
                                        </li>
                                    </ul>
                                    <ul class="search-form-content">
                                        <li class="form-item"><label class="search-form-lable">发布时间</label>
                                            <div class="check-btn-inner" id="timeType">
                                                <a id="all" href="javascript:void(0);"
                                                   onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                                <a href="javascript:void(0);"
                                                   onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                                <input type="hidden" name="timeType" value="${input.timeType}"/>
                                            </div>
                                            <div class="layui-inline">
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createStart" value="${input.createStart}" placeholder="开始日">
                                                </div>
                                                -
                                                <div class="layui-input-inline">
                                                    <input class="layui-input" type="text" name="createEnd" value="${input.createEnd}" placeholder="截止日">
                                                </div>
                                            </div>
                                        </li>
                                        <li class="form-item-inline">
                                            <div class="sub-btns">
                                                <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                                <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </form>
                        <div class="c-time-list-content">
                            <ul>
                                <c:if test="${page.totalCount == 0}">
                                    <div class="f16 tc mt15">还没有数据，请点击右上角的“发布众筹项目”，发布和编辑内容</div>
                                </c:if>
                                <c:set var="nowDate" value="<%=new Date()%>"></c:set>
                                <c:forEach var="activity" items="${activities}">
                                    <li>
                                        <div class="detail-content">
                                            <a href="${ctx}/activity/activity/zcActivityDetail.do?actId=${activity.id}"
                                               target="_self" class="act-logo common-img">
                                                <img src="<c:if test="${activity.pic != null}">${activity.pic}?imageMogr2/auto-orient/crop/200x150</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                            </a>
                                            <div class="detail">
                                                <div class="act-title">
                                                    <c:choose>
                                                        <c:when test="${activity.checkStatus == 0}">
                                                            <span class="status f20 red">审核中</span>
                                                        </c:when>
                                                        <c:when test="${activity.checkStatus == 1}">
                                                            <c:if test="${activity.endTime > nowDate}">
                                                                <span class="status f20 red">进行中</span>
                                                            </c:if>
                                                            <c:if test="${activity.endTime < nowDate}">
                                                                <span class="status f18 dark">已截止</span>
                                                            </c:if>
                                                        </c:when>
                                                        <c:when test="${activity.checkStatus == 2}">
                                                            <span class="status f18 dark">已拒绝</span>
                                                        </c:when>
                                                    </c:choose>
                                                    <a title="${activity.title}"
                                                       href="${ctx}/activity/activity/zcActivityDetail.do?actId=${activity.id}"
                                                       target="_self"
                                                       class="title f18 ell db">${activity.title}</a>
                                                </div>
                                                <div>
                                                    <c:if test="${activity.isMultiple == 0}">
                                                        <p class="act-price">
                                                            <span style="margin-right: 10px;">截止时间：<fmt:formatDate value="${activity.endTime}" pattern="yyyy-MM-dd HH:mm"/></span>
                                                            <span style="margin-right: 10px;">报名费用：<b class="active-red"><fmt:formatNumber value="${activity.price}" pattern="0.00"/></b>元/位</span>
                                                            <span>活动地点：${activity.place}</span>
                                                        </p>
                                                    </c:if>
                                                    <p class="act-price">
                                                        <span class="mr10">主题名称：<b class="active-red">${activity.eventName}</b></span>
                                                        <c:if test="${sessionScope.newCurrentUser.id != activity.memberId}">
                                                            <span>发布者：<b class="active-red">${activity.member}</b></span>
                                                        </c:if>
                                                    </p>
                                                    <p class="act-price">
                                                        <span class="mr10">
                                                            报名人数：<strong class="red">${activity.joinNum}</strong>&nbsp;人
                                                        </span>
                                                        <c:if test="${activity.isMultiple == 0}">
                                                            <span class="mr10">
                                                                众筹成功：<strong class="red">${activity.crowdfundedNum}</strong>&nbsp;人
                                                            </span>
                                                        </c:if>
                                                        <span class="mr10">
                                                            支持人数：<strong class="red">${activity.favorerNum}</strong>&nbsp;人
                                                        </span>
                                                        <span>
                                                            已筹金额：<strong class="red"><fmt:formatNumber value="${activity.totalMoney}" pattern="0.00"/></strong>&nbsp;元
                                                        </span>
                                                    </p>
                                                    <p class="act-price">
                                                        <span class="mr10">发布时间：<fmt:formatDate value="${activity.createDate}" pattern="yyyy-MM-dd HH:mm"/></span>
                                                        <span class="mr10">修改时间：<fmt:formatDate value="${activity.updateDate}" pattern="yyyy-MM-dd HH:mm"/></span>
                                                    </p>
                                                </div>
                                                <div class="opts-btns tb-opts" style="width:475px;">
                                                    <div class="comm-opts">
                                                        <c:if test="${activity.isMultiple == 0}">
                                                            <a class="qr-btn" href="javascript:txz.openQrDialog({
                                                                title:'扫码二维码可预览分享',
                                                                detailList:[{
                                                                    title:'报名二维码',
                                                                    url:'${activity.qrCodeMap.detailQrCode}',
                                                                    link:'${activity.qrCodeMap.detailQrCodeContent}'
                                                                },{
                                                                    title:'联合发起二维码',
                                                                    url:'${activity.qrCodeMap.dyQrCode}',
                                                                    link:'${activity.qrCodeMap.dyQrCodeContent}'
                                                                },{
                                                                    title:'直接付款二维码',
                                                                    url:'${activity.qrCodeMap.dpDetailQrCode}',
                                                                    link:'${activity.qrCodeMap.dpDetailQrCodeContent}'
                                                                }]
                                                            })"><i class="iconfont icon-qrcode btn-icon"></i> 二维码</a>
                                                        </c:if>
                                                        <c:if test="${activity.isMultiple == 1}">
                                                            <a class="qr-btn" href="javascript:txz.openQrDialog({
                                                                title:'扫码二维码可预览分享',
                                                                detailList:[{
                                                                    title:'报名二维码',
                                                                    url:'${activity.qrCodeMap.detailQrCode}',
                                                                    link:'${activity.qrCodeMap.detailQrCodeContent}'
                                                                },{
                                                                    title:'联合发起二维码',
                                                                    url:'${activity.qrCodeMap.dyQrCode}',
                                                                    link:'${activity.qrCodeMap.dyQrCodeContent}'
                                                                }]
                                                            })"><i class="iconfont icon-qrcode btn-icon"></i> 二维码</a>
                                                        </c:if>
                                                        <c:if test="${activity.isMultiple == 0}">
                                                            <a href="${ctx}/activity/activity/zcCrowdfundList.do?id=${activity.id}">
                                                                <i class="iconfont icon-searchlist btn-icon"></i>
                                                                数据查看
                                                            </a>
                                                            <shiro:hasPermission name="crowdfund:event:analyze">
                                                                <a target="_blank"
                                                                   href="${ctx}/crowdfund/analyze/list.do?targetId=${activity.id}">
                                                                    <i class="iconfont icon-news btn-icon"></i>
                                                                    数据分析
                                                                </a>
                                                            </shiro:hasPermission>
                                                            <a href="${ctx}/notify/template/list.do?targetId=${activity.id}">
                                                                <i class="iconfont icon-mail btn-icon"></i>
                                                                短信推送
                                                            </a>
                                                            <a href="javascript:txz.expireCheck('', function() {
                                                                openDialogCooperateChannel('添加合作渠道——${activity.title}', '${ctx}/activity/zcActivity/toFormCooperateChannel.do?activityId=${activity.id}', '580px', '680px')
                                                            })">
                                                                <i class="iconfont icon-hezuo btn-icon"></i>
                                                                合作渠道
                                                            </a>
                                                            <c:if test="${activity.endTime > nowDate}">
                                                                <a href="javascript:txz.expireCheck('${ctx}/crowdfund/target/copyView.do?id=${activity.id}')">
                                                                    <i class="iconfont icon-copy btn-icon"></i> 复制</a>
                                                            </c:if>
                                                            <a href="${ctx}/activity/activity/publishZcAct.do?id=${activity.id}">
                                                                <i class="iconfont icon-edit btn-icon"></i>
                                                                编辑
                                                            </a>
                                                        </c:if>
                                                        <c:if test="${activity.isMultiple == 1}">
                                                            <a href="${ctx}/activityMultiple/project/listForActivity.do?id=${activity.id}">
                                                                <i class="iconfont icon-searchlist btn-icon"></i>
                                                                数据查看
                                                            </a>
                                                            <shiro:hasPermission name="crowdfund:event:analyze">
                                                                <a target="_blank" href="${ctx}/activityMultiple/project/analyzeList.do?targetId=${activity.id}">
                                                                    <i class="iconfont icon-news btn-icon"></i>
                                                                    数据分析
                                                                </a>
                                                            </shiro:hasPermission>
                                                            <c:if test="${activity.endTime > nowDate}">
                                                                <a href="javascript:txz.expireCheck('${ctx}/activityMultiple/zcActivity/copyView.do?id=${activity.id}')">
                                                                    <i class="iconfont icon-copy btn-icon"></i> 复制</a>
                                                            </c:if>
                                                            <a href="${ctx}/activityMultiple/zcActivity/publishZcAct.do?id=${activity.id}">
                                                                <i class="iconfont icon-edit btn-icon"></i>
                                                                编辑
                                                            </a>
                                                        </c:if>
                                                        <a href="javascript:txz.deleteObject('确定要删除众筹项目吗？', '${ctx}/activity/activity/deleteLogic.do?id=${activity.id}')">
                                                            <i class="iconfont icon-delete btn-icon"></i> 删除
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </li>
                                </c:forEach>
                            </ul>
                        </div>
                        <div class="page-content">
                            <div id="page_content" class="page-container"></div>
                        </div>
                    <%--</div>
                </div>
            </div>--%>
        </div>
        <!--底部-->
        <%@include file="../include/footer.jsp" %>
    </section>

</div>

<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">
    txz.initHeader({
        nav:[{
            name: '众筹项目',
            curr: true
        }],
        info:'<span class="f14 gray">众筹是一款可以针对活动或是项目或是产品，编辑和发起的筹款功能</span>\n' +
        '<a href="javascript:openHelpDialog()" class="red ml10"><i class="iconfont icon-mobile"></i>手机端效果</a>\n' +
        '<a href="${ctx}/help/help/list.do?id=30986da5be0245e58ec1b410d6a062a6" class="red ml10" target="_blank"><i class="iconfont icon-book"></i>帮助教程</a>',
        btns:[{
            name: '发布众筹项目',
            icon: 'add',
            href: '${ctx}/activity/activity/publishZcAct.do',
            isCheckExpire: true
        }]
    });
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['element', 'laydate'], function () {
            var element = layui.element,laydate = layui.laydate;

            element.on('tab(type)', function (data) {
                var isCopartner = $("#copartner_tab li.layui-this").attr("data-isCopartner");
                var status = $("#zc_tab li.layui-this").attr("data-status");
                $('#status').val(status);
                $('#isCopartner').val(isCopartner);
                $('#myForm').submit();
            });
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })
    function openHelpDialog() {
        txz.openHelpDialog({
            title: '手机效果预览',
            describe: '点击发布众筹活动，填写活动描述、报名相关信息、参赛标准等内容之后，即可发布众筹活动生成二维码，分享给想要邀请的用户，用户扫描二维码即可参与众筹报名。',
            detailList: [{
                text: '1/众筹项目详情',
                url: '${ctx}/image/dialog/zc_1.jpg'
            },{
                text: '2/活动详情',
                url: '${ctx}/image/dialog/zc_2.jpg'
            },{
                text: '3/活动信息',
                url: '${ctx}/image/dialog/zc_3.jpg'
            }]
        })
    }
    function copy(id) {
        var confirmIndex = layer.confirm('确认复制众筹项目所有内容吗?', {title: '系统提示'}, function (index) {
            layer.close(confirmIndex);
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/crowdfund/target/copy.do", {
                id: id
            }, function (data) {
                top.layer.close(loadIndex);
                if (data.success) {
                    util.layerAlertSuccess("复制成功", function () {
                        window.location.reload();
                    })
                } else {
                    util.layerAlertError(data.description)
                }
            });
        });
    }

    function createCircle(actId) {
        var content = "确定要生成吗？请选择生成<br/><label for='all1' class='mr10'><input type='radio' id='all1' name='type' value='2' checked='checked' >全部报名人员</label>" +
            "<label for='success'><input type='radio' id='success' name='type' value='1' >已成功报名人员</label>";
// 		content = "确定要生成吗？";
        layer.confirm(content, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            var type = $("[name=type]:checked").val() || '2';
            layer.close(index);
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/activity/activity/createCircle.do", {
                actId: actId,
                type: type
            }, function (data) {
                layer.close(loadIndex);
                setTimeout(function () {
                    if (data.success) {
                        util.layerMsgSuccess("生成成功")
                    } else {
                        util.layerMsgError("生成失败")
                    }
                });
            })
        });
    }

    /**
     * 合作渠道弹窗
     * @param activityId 活动id
     */
    function openDialogCooperateChannel(title, url, width, height, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }

            },
            cancel: function (index) {
            }
        });
    }
</script>
</body>
</html>